//
//  WPHomePageViewController.m
//  ZhongChouPingTai
//
//  Created by WeiPan on 16/3/30.
//  Copyright © 2016年 HuaYiSoftware. All rights reserved.
//

#import "WPHomePageViewController.h"
#import "WPNewsPreheatModel.h"
#import "WPNewsPreheatTableViewCell.h"
#import "WPNewsDealingModel.h"
#import "WPNewsDealingTableViewCell.h"
#import "WPGetToken.h"

static CGFloat timerInterval = 3.0f;
static NSInteger BtnTag = 100;
@interface WPHomePageViewController ()<UIScrollViewDelegate, UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate>{
    NSMutableArray *_iamgeViews;/**< 存储图片视图 */
    NSMutableArray *_imageNames;/**< 存储图片名字 */
    NSMutableArray * _urlImageNames;/**< 网络图片名字 */
    NSMutableArray * _urlArray;/**< 活动网址 */
}
@property (nonatomic, strong) UIView * statusBackView;/**< 导航栏背景图 */
@property (nonatomic, strong) UILabel * titleLabel;/**< 标题文本 */
@property (nonatomic, strong) UIScrollView * backScrollView;/**< 整体滚动视图 */
@property (nonatomic, strong) UIScrollView * imageScrollView;/**< 轮播视图 */
@property (nonatomic, strong) UIPageControl * pageControl;/**< 分页显示器 */
@property (nonatomic, strong) NSTimer * timer;/**< 计时器 */

@property (nonatomic, strong) UITextField * tradeCountTextField;/**< 累计交易人次 */
@property (nonatomic, strong) UIImageView * chartImageView;/**< 折线图 */
@property (nonatomic, strong) UIView * lineView;/**< 线 */
@property (nonatomic, strong) UITextField * scrollNewsTextField;/**< 滚动新闻 */

@property (nonatomic, strong) UIView * headView;/**< 列表表头 */
@property (nonatomic, strong) UIView * footView;/**< 列表表尾 */
@property (nonatomic, strong) UITableView * newsTableView;/**< 新闻滚动列表 */
@property (nonatomic, strong) NSMutableArray * newsArr;/**< 新闻数据源 */
@property (nonatomic, strong) NSArray * nextVCArr;/**< 下一界面控制器数组 */
- (void)initializeDataSource; /**< 初始化数据源 */
- (void)initializeUserInterface; /**< 初始化用户界面 */
- (void)refreshData;/**< 刷新数据 */
- (void)insertImageViewInScroll;/**< 在滚动视图中插入3个图片视图 */
- (void)insertImageInImageView;/**< 在图片视图上显示图片 */


@end

@implementation WPHomePageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    if (![[NSUserDefaults standardUserDefaults]stringForKey:@"token"]) {
        [WPGetToken getTokenWithSuccessBlock:^(NSString *succ) {
            
        } andWithFailureBlock:^(NSString *fail) {
            
        }];
//    }
    
    [self initializeDataSource];
    [self initializeUserInterface];
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = YES;
    self.timer.fireDate = [NSDate distantPast];
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    //暂停timer
    [self.timer setFireDate:[NSDate distantFuture]];
    self.navigationController.navigationBarHidden = NO;

}
#pragma mark - init
- (void)initializeDataSource {
    _imageNames = [NSMutableArray arrayWithArray:@[@"banner1.png", @"banner2.png", @"banner3.png", @"banner4.png"]];
    self.nextVCArr = @[@[@"WPRewardsViewController" , @""], @[@"WPStockViewController", @"股权众筹"], @[@"WPOneIndianaViewController", @"一元夺宝"], @[@"WPHotTradeViewController", @"交易热区"]];
    self.newsArr = [NSMutableArray arrayWithCapacity:0];
    WPNewsPreheatModel * model = [WPNewsPreheatModel new];
    model.posterImageName = @"banner1.png";
    model.title = @"The squall Rain亚洲演唱会";
    model.detail = @"违法龙卷风甲方垃圾分类加了福建福利及发洛杉矶大连三姐夫龙卷风龙卷风垃圾按缴费卡九分裤积分卡了解封了案件发空间分类";
    model.attentionCount = @"40000";
    model.leftDays = @"12";
    
    WPNewsDealingModel * model1 = [WPNewsDealingModel new];
    model1.posterImageName = @"banner1.png";
    model1.title = @"The squall Rain亚洲演唱会";
    model1.detail = @"违法龙卷风甲方垃圾分类加了福建福利及发洛杉矶大连三姐夫龙卷风龙卷风垃圾按缴费卡九分裤积分卡了解封了案件发空间分类";
    model1.ticketCount = @"750";
    model1.allTicketCount = @"800";
    model1.joinCount = @"200";
    model1.leftDays = @"8";
    for (int i = 0; i < 2; i++) {
        [_newsArr addObject:model];
    }
    [_newsArr addObject:model1];
}
- (void)initializeUserInterface {
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.statusBackView];
    [self.view addSubview:self.titleLabel];
    [self.view addSubview:self.backScrollView];
    [self.backScrollView addSubview:self.imageScrollView];
    [self.backScrollView addSubview:self.pageControl];
    [self insertImageViewInScroll];
    [self insertImageInImageView];
    [self configButton];
    [self configGraySeparaViewWithOriginY:CGRectGetMaxY(self.imageScrollView.frame)+70*DHFlexibleHorizontalMutiplier()];
    [self.backScrollView addSubview:self.tradeCountTextField];
    [self.backScrollView addSubview:self.chartImageView];
    [self.backScrollView addSubview:self.lineView];
    [self.backScrollView addSubview:self.scrollNewsTextField];
    [self configGraySeparaViewWithOriginY:CGRectGetMaxY(self.scrollNewsTextField.frame)];
    [self.backScrollView addSubview:self.newsTableView];
}
#pragma mark - responds events
- (void)respondsToTimer {
    [self.imageScrollView setContentOffset:CGPointMake(2*CGRectGetWidth(self.view.bounds), 0) animated:YES];
}
- (void)respondsToImageViewTap {
    
}
- (void)respondsToKindBtn:(UIButton *)sender {
    [self pushToNextController:[[NSClassFromString(_nextVCArr[sender.tag - BtnTag][0]) alloc]init] withVCTitle:_nextVCArr[sender.tag - BtnTag][1]];
}
- (void)respondsToMoreReturnBtn {
    [self pushToNextController:[[NSClassFromString(@"WPRewardsViewController") alloc]init] withVCTitle:@""];
}
#pragma mark - 刷新数据
- (void)refreshData {
    
}
#pragma mark - UITextField Protocol
- (void)textFieldDidBeginEditing:(UITextField *)textField {
    [self respondsToMoreReturnBtn];
}
#pragma mark - 协议UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return _newsArr.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section != _newsArr.count - 1) {
        WPNewsPreheatTableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        if (!cell) {
            cell = [[WPNewsPreheatTableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"123"];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.accessoryType = UITableViewCellAccessoryNone;
        [cell setModelWithModel:_newsArr[indexPath.section]];
        return cell;
    }
    WPNewsDealingTableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    if (!cell) {
        cell = [[WPNewsDealingTableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"1234"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.accessoryType = UITableViewCellAccessoryNone;
    [cell setModelWithModel:_newsArr[indexPath.section]];
    return cell;
}
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 10;
}
//设置每一行高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 280*DHFlexibleHorizontalMutiplier();
}
//用户点击了某一行
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
}

#pragma mark - 滚动视图协议
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    if (scrollView == _newsTableView) {
        return;
    }
    //往右滑
    if (scrollView.contentOffset.x >= 2*CGRectGetWidth(self.view.bounds)) {
        if (_urlImageNames.count) {
            NSString *firstObject = [_urlImageNames.firstObject mutableCopy];
            [_urlImageNames removeObjectAtIndex:0];
            [_urlImageNames addObject:firstObject];
            self.pageControl.currentPage = self.pageControl.currentPage == _urlImageNames.count - 1? 0:self.pageControl.currentPage+1;
        } else {
            NSString *firstObject = [_imageNames.firstObject mutableCopy];
            [_imageNames removeObjectAtIndex:0];
            [_imageNames addObject:firstObject];
            self.pageControl.currentPage = self.pageControl.currentPage == _imageNames.count - 1? 0:self.pageControl.currentPage+1;
        }
    }
    //往左滑
    else if (scrollView.contentOffset.x <= 0) {
        if (_urlImageNames.count) {
            NSString *lastObject = [_urlImageNames.lastObject mutableCopy];
            [_urlImageNames removeObject:lastObject];
            [_urlImageNames insertObject:lastObject atIndex:0];
            self.pageControl.currentPage = self.pageControl.currentPage == 0? _urlImageNames.count - 1:self.pageControl.currentPage-1;
        } else {
            NSString *lastObject = [_imageNames.lastObject mutableCopy];
            [_imageNames removeObject:lastObject];
            [_imageNames insertObject:lastObject atIndex:0];
            self.pageControl.currentPage = self.pageControl.currentPage == 0? _imageNames.count - 1:self.pageControl.currentPage-1;
        }
        
    }else {
        //停在中间
        return;
    }
    [self insertImageInImageView];
    //更新偏移量
    scrollView.contentOffset = CGPointMake(CGRectGetWidth(scrollView.bounds), 0);
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
    //暂停timer
    if (scrollView == _newsTableView) {
        return;
    }
    _timer.fireDate = [NSDate distantFuture];
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    //从结束拖动开始计算延迟2s再启动
    if (scrollView == _newsTableView) {
        return;
    }
    _timer.fireDate = [NSDate dateWithTimeIntervalSinceNow:timerInterval];
}
#pragma mark - private methods
- (void)insertImageViewInScroll {
    _iamgeViews = [NSMutableArray arrayWithCapacity:0];
    for (int i = 0; i < 3; i++) {
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(i*SCREEN_SIZE.width, 0, SCREEN_SIZE.width, CGRectGetHeight(self.imageScrollView.bounds))];
        imageView.userInteractionEnabled = YES;
        UITapGestureRecognizer * tapges = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(respondsToImageViewTap)];
        [imageView addGestureRecognizer:tapges];
        [_imageScrollView addSubview:imageView];
        //将图片视图植入——imageViews 便于便利数组
        [_iamgeViews addObject:imageView];
    }
}
- (void)insertImageInImageView {
    NSInteger index = 0;
    for (UIImageView *imageView in _iamgeViews) {
        if (_urlImageNames.count) {
            index = index == _urlImageNames.count ? _urlImageNames.count - 1:index;
            NSURL * imageUrl = [NSURL URLWithString:_urlImageNames[index]];
            UIImage * placeImge = imageView.image;
            [imageView sd_setImageWithURL:imageUrl placeholderImage:placeImge];
        } else {
            imageView.image = IMAGE_NAME(_imageNames[index]);
        }
        index++;
    }
}
- (void)configGraySeparaViewWithOriginY:(CGFloat)y {
    UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, y, SCREEN_SIZE.width, 10*DHFlexibleHorizontalMutiplier())];
    view.backgroundColor = COLOR_RGB(244, 244, 244, 1);
    [self.backScrollView addSubview:view];
}
- (void)configButton {
    NSArray * btnImages = @[@"回报项目.png", @"股权众筹.png", @"一元夺宝.png", @"交易热区.png"];
    for (int i = 0; i < btnImages.count; i++) {
        UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.bounds = CGRectMake(0, 0, 48*DHFlexibleHorizontalMutiplier(), 56*DHFlexibleHorizontalMutiplier());
        btn.center = CGPointMake((35+i*80)*DHFlexibleHorizontalMutiplier(), CGRectGetMaxY(self.imageScrollView.frame)+ 35*DHFlexibleHorizontalMutiplier());
        [btn setImage:IMAGE_NAME(btnImages[i]) forState:UIControlStateNormal];
        btn.tag = BtnTag+i;
        [btn addTarget:self action:@selector(respondsToKindBtn:) forControlEvents:UIControlEventTouchUpInside];
        [_backScrollView addSubview:btn];
    }
}

#pragma mark - getter
- (UIView *)statusBackView {
    if (!_statusBackView) {
        _statusBackView = ({
            UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_SIZE.width, navBar_Fheight)];
            view.backgroundColor = COLOR_RGB(234, 27, 47, 1);
            view;
        });
    }
    return _statusBackView;
}
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = ({
            UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(0, staBar_height, SCREEN_SIZE.width, navBar_height)];
            lab.textColor = [UIColor whiteColor];
            lab.textAlignment = NSTextAlignmentCenter;
            lab.font = [UIFont boldSystemFontOfSize:16*DHFlexibleHorizontalMutiplier()];
            lab.text = @"票票来";
            lab;
        });
    }
    return _titleLabel;
}
- (UIScrollView *)backScrollView {
    if (!_backScrollView) {
        _backScrollView = ({
            UIScrollView * view = [[UIScrollView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.statusBackView.frame), SCREEN_SIZE.width, SCREEN_SIZE.height - CGRectGetMaxY(_statusBackView.frame))];
            view.showsVerticalScrollIndicator = NO;
            view.bounces = NO;
            view.backgroundColor = [UIColor whiteColor];
            view.directionalLockEnabled = YES;
            view.contentSize = CGSizeMake(0, 2000);
            view;
        });
    }
    return _backScrollView;
}
- (UIScrollView *)imageScrollView {
    if (!_imageScrollView) {
        _imageScrollView = ({
            UIScrollView * view = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_SIZE.width, 170*DHFlexibleHorizontalMutiplier())];
            view.showsHorizontalScrollIndicator = NO;
            view.showsVerticalScrollIndicator = NO;
            view.pagingEnabled = YES;
            view.bounces = NO;
            view.delegate = self;
            view.contentSize = CGSizeMake(CGRectGetWidth(self.view.frame)*3, 0);
            view.contentOffset = CGPointMake(CGRectGetWidth(view.bounds), 0);
            view;
        });
    }
    return _imageScrollView;
}
- (UIPageControl *)pageControl {
    if (!_pageControl) {
        _pageControl = ({
            UIPageControl * control = [[UIPageControl alloc]initWithFrame:CGRectMake(250*DHFlexibleHorizontalMutiplier(), CGRectGetMaxY(self.imageScrollView.frame) - 30*DHFlexibleHorizontalMutiplier(), 50*DHFlexibleHorizontalMutiplier(), 30*DHFlexibleHorizontalMutiplier())];
            control.numberOfPages = _imageNames.count;
            control.currentPage = 0;
            control.hidesForSinglePage = YES;
            control.pageIndicatorTintColor = COLOR_RGB(230, 231, 232, 1);
            control.currentPageIndicatorTintColor = COLOR_RGB(140, 141, 145, 1);
            control;
        });
    }
    return _pageControl;
}

- (NSTimer *)timer {
    if (!_timer) {
        _timer = [NSTimer scheduledTimerWithTimeInterval:timerInterval target:self selector:@selector(respondsToTimer) userInfo:nil repeats:YES];
    }
    return _timer;
}
- (UITextField *)tradeCountTextField {
    if (!_tradeCountTextField) {
        _tradeCountTextField = ({
            UITextField * text = [[UITextField alloc]initWithFrame:CGRectMake(0, 255*DHFlexibleHorizontalMutiplier(), SCREEN_SIZE.width, 40*DHFlexibleHorizontalMutiplier())];
            text.leftViewMode = UITextFieldViewModeAlways;
            text.rightViewMode = UITextFieldViewModeAlways;
            UILabel * leftLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 110*DHFlexibleHorizontalMutiplier(), 40*DHFlexibleHorizontalMutiplier())];
            leftLabel.font = [UIFont systemFontOfSize:14*DHFlexibleHorizontalMutiplier()];
            leftLabel.textAlignment = NSTextAlignmentRight;
            leftLabel.text = @"累计交易:";
            UILabel * rightLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 80*DHFlexibleHorizontalMutiplier(), 40*DHFlexibleHorizontalMutiplier())];
            rightLabel.font = [UIFont systemFontOfSize:14*DHFlexibleHorizontalMutiplier()];
            rightLabel.text = @"人次";
            text.leftView = leftLabel;
            text.rightView = rightLabel;
            text.font = [UIFont systemFontOfSize:14*DHFlexibleHorizontalMutiplier()];
            text.textAlignment = NSTextAlignmentCenter;
            text.textColor = COLOR_RGB(234, 27, 47, 1);
            text.userInteractionEnabled = NO;
            text.text = @"1 2 4 8 2 4 7";
            text;
        });
    }
    return _tradeCountTextField;
}
- (UIImageView *)chartImageView {
    if (!_chartImageView) {
        _chartImageView = ({
            UIImageView * view = [[UIImageView alloc]initWithFrame:CGRectMake(6*DHFlexibleHorizontalMutiplier(), CGRectGetMaxY(self.tradeCountTextField.frame)+10*DHFlexibleHorizontalMutiplier(), 308*DHFlexibleHorizontalMutiplier(), 128*DHFlexibleHorizontalMutiplier())];
            view.image = IMAGE_NAME(@"sjimage.png");
            view;
        });
    }
    return _chartImageView;
}
- (UIView *)lineView {
    if (!_lineView) {
        _lineView = ({
            UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.chartImageView.frame)+12*DHFlexibleHorizontalMutiplier(), SCREEN_SIZE.width, 1)];
            view.backgroundColor = COLOR_RGB(222, 222, 222, 1);
            view;
        });
    }
    return _lineView;
}
- (UITextField *)scrollNewsTextField {
    if (!_scrollNewsTextField) {
        _scrollNewsTextField = ({
            UITextField * text  = [[UITextField alloc]initWithFrame:CGRectMake(10*DHFlexibleHorizontalMutiplier(), CGRectGetMaxY(self.lineView.frame), 300*DHFlexibleHorizontalMutiplier(), 30*DHFlexibleHorizontalMutiplier())];
            text.leftViewMode = UITextFieldViewModeAlways;
            UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 90, 30*DHFlexibleHorizontalMutiplier())];
            label.textColor = COLOR_RGB(153, 188, 216, 1);
            label.font = [UIFont systemFontOfSize:12*DHFlexibleHorizontalMutiplier()];
            label.text = @"180080***380";
            text.leftView = label;
            text.font = [UIFont systemFontOfSize:12*DHFlexibleHorizontalMutiplier()];
            text.text = @"用户： ”The Squall“ Rain亚洲演唱会";
            text.userInteractionEnabled = NO;
            text;
        });
    }
    return _scrollNewsTextField;
}
- (UIView *)headView {
    if (!_headView) {
        _headView = ({
            UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.scrollNewsTextField.frame)+10*DHFlexibleHorizontalMutiplier(), SCREEN_SIZE.width, 30*DHFlexibleHorizontalMutiplier())];
            view.backgroundColor = [UIColor whiteColor];
            UIView * line = [[UIView alloc]initWithFrame:CGRectMake(10*DHFlexibleHorizontalMutiplier(), 9*DHFlexibleHorizontalMutiplier(), 2, 12*DHFlexibleHorizontalMutiplier())];
            line.backgroundColor = COLOR_RGB(237, 27, 47, 1);
            [view addSubview:line];
            UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(15*DHFlexibleHorizontalMutiplier(), 0, 200, 30*DHFlexibleHorizontalMutiplier())];
            label.font = [UIFont systemFontOfSize:12*DHFlexibleHorizontalMutiplier()];
            label.text = @"回报项目";
            [view addSubview:label];
            UITextField * text = [[UITextField alloc]initWithFrame:CGRectMake(270*DHFlexibleHorizontalMutiplier(), 0, 35*DHFlexibleHorizontalMutiplier(), 30*DHFlexibleHorizontalMutiplier())];
            text.rightViewMode = UITextFieldViewModeAlways;
            UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
            btn.frame = CGRectMake(0, 10*DHFlexibleHorizontalMutiplier(), 5*DHFlexibleHorizontalMutiplier(), 9*DHFlexibleHorizontalMutiplier());
            [btn setImage:IMAGE_NAME(@"iconfont-xialaanniu.png") forState:UIControlStateNormal];
            [btn addTarget:self action:@selector(respondsToMoreReturnBtn) forControlEvents:UIControlEventTouchUpInside];
            text.rightView = btn;
            text.font = [UIFont systemFontOfSize:10*DHFlexibleHorizontalMutiplier()];
            text.textColor = COLOR_RGB(224, 224, 224, 1);
            text.text = @"更多";
            text.delegate = self;
            [view addSubview:text];
            view;
        });
    }
    return _headView;
}
- (UIView *)footView {
    if (!_footView) {
        _footView = ({
            UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_SIZE.width, 70*DHFlexibleHorizontalMutiplier())];
            UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(0, 20*DHFlexibleHorizontalMutiplier(), SCREEN_SIZE.width, 30*DHFlexibleHorizontalMutiplier())];
            lab.textAlignment = NSTextAlignmentCenter;
            lab.textColor = COLOR_RGB(141, 141, 141, 1);
            lab.font = [UIFont systemFontOfSize:12*DHFlexibleHorizontalMutiplier()];
            lab.text = @"没有更多数据啦";
            [view addSubview:lab];
            view;
        });
    }
    return _footView;
}
- (UITableView *)newsTableView {
    if (!_newsTableView) {
        _newsTableView = ({
            UITableView * tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.scrollNewsTextField.frame)+10*DHFlexibleHorizontalMutiplier(), SCREEN_SIZE.width, 1000) style:UITableViewStyleGrouped];
            tableview.dataSource = self;
            tableview.delegate = self;
            tableview.tableHeaderView = self.headView;
            tableview.tableFooterView = self.footView;
            tableview.pagingEnabled = NO;
            tableview.bounces = YES;
            tableview.separatorColor = [UIColor clearColor];
            tableview.scrollEnabled = NO;
            tableview.backgroundColor = [UIColor whiteColor];
            tableview;
        });
    }
    return _newsTableView;
}
@end
